package pl.vanta.utils.ejb.ejbqlb.conditions;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import pl.vanta.utils.ejb.ejbqlb.connectors.AbstractConnector;
import pl.vanta.utils.ejb.ejbqlb.connectors.AndConnector;
import pl.vanta.utils.ejb.ejbqlb.connectors.OrConnector;
import pl.vanta.utils.ejb.ejbqlb.parts.Where;

public abstract class AbstractCondition
{
	public AbstractConnector	AND;
	public AbstractConnector	OR;

	protected ConditionType		operatorType;
	protected List<Object>		values;

	public AbstractCondition(Where where, ConditionType operatorType)
	{
		this.values = new ArrayList<Object>();
		this.operatorType = operatorType;

		this.AND = new AndConnector(where);
		this.OR = new OrConnector(where);
	}

	public AbstractCondition(Where where, ConditionType operatorType, Object value)
	{
		this(where, operatorType);

		this.values.add(value);
	}

	public AbstractCondition(Where where, ConditionType operatorType, Object value1, Object value2)
	{
		this(where, operatorType);

		this.values.add(value1);
		this.values.add(value2);
	}

	public AbstractCondition(Where where, ConditionType operatorType, Object... value)
	{
		this(where, operatorType);

		this.values.addAll(Arrays.asList(value));
	}
}